<template>
  <div class="shopadress-content">
    <van-cell-group>
      <van-field v-model="address" label="市区" placeholder="请选择区域"/>
      <van-field v-model="box" label="餐盒费" placeholder="请输入餐盒费"/>
      <div class="opacitybtn" @click="Suk_show"></div>
      <van-popup v-model="show" position="bottom">
        <van-area :area-list="areaList" @confirm="Suk_confirm" @cancel="Suk_cancel"/>
      </van-popup>
      <van-field v-model="addressdetail" label="详细地址" placeholder="请输入详细地址" type="textarea"/>
    </van-cell-group>
    <div class="savebtn" @click="Suk_editshoptel">保存</div>
  </div>
</template>

<script>
import areaList from "@/assets/area.js";
export default {
  data() {
    return {
      box:null,
      show: false,
      address: null,
      addressdetail: null,
      areaList,
      searchResult: []
    };
  },
  beforeCreate: function() {
    //创建前
  },
  created: function() {
    //创建后

  },
  beforeMount: function() {
    //挂载前
  },
  mounted: function() {
    //挂载后
  },
  beforeUpdate: function() {
    //更新前
  },
  update: function() {
    //更新后
  },
  methods: {
    Suk_confirm(e) {
      let that = this;
      that.address = e[0].name + " " + e[1].name + " " + e[2].name;
      that.show = false
    },
    Suk_cancel() {
      this.show = false
    },
    Suk_show() {
      let that = this;
      that.show = true;
    },
    Suk_editshoptel() {
      let that = this;
      that.$toast.loading({
        message: "加载中..."
      });
      var Sukdata = {
//      id: localStorage.getItem("storeid"),
				userid: localStorage.getItem("userid"),
        address: that.address + that.addressdetail,
        box:that.box
      };
      console.log(Sukdata);
      that.axios
        .post(
          that.baseUrl + "/dining/updateImages",
          that.Qs.stringify(Sukdata),
          {
            headers: {
              "Content-Type": "application/x-www-form-urlencoded"
            }
          }
        )
        .then(function(res) {
          if (res.data.meta.code == -1) {
//            console.log(res.data);
              that.$toast.success({
                message: "商家不存在！"
              });
            } else if (res.data.meta.code == 1) {
            	that.$toast.success({
                message: "修改成功！"
              });
              that.$router.go(-1)
            }else if (res.data.meta.code == -2) {
            	that.$toast.success({
                message: "修改失败！"
              });
          }
        });
    },
    onSave() {
      Toast("save");
    },
    onDelete() {
      Toast("delete");
    }
  }
};
</script>
<style lang="scss" scoped>
.savebtn {
  background: #fda229;
  width: 80%;
  font-size: 0.44rem;
  text-align: center;
  color: #fff;
  height: 1.1rem;
  line-height: 1.1rem;
  margin: 2rem auto;
  border-radius: 0.5rem;
  -webkit-box-shadow: 0rem 0.05rem 0.2rem 0.1rem #e7e7e7;
  box-shadow: 0rem 0.05rem 0.2rem 0.1rem #e7e7e7;
}
.opacitybtn {
  width: 100%;
  background: red;
  height: 1rem;
  opacity: 0;
  position: absolute;
  z-index: 999;
  top: 0.1rem;
}
</style>
